package com.java.file.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author jl
 * Created on 2020/10/8
 */
@Configuration
public class SpringMVConfig implements WebMvcConfigurer {
    @Value("${file.path}")
    private String FILE_PATH;

    /**
     * SpringBoot静态资源配置,包括图片、CSS、JS等
     *  String fullPath = "D:/picture/jl-course/teacher/"+pre+"-"+originalFilename;
     *  http://127.0.0.1:9003/file/f/teacher/xx.png
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/f/**").addResourceLocations("file:"+ FILE_PATH);  // D:/picture/jl-course/
    }
}
